package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.Location;
import com.itheima.service.LocationService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mobileLocation")
public class MoblieLocationController {
    @Reference
    private LocationService locationService;

    /**
     * 查询所有地址信息
     * @return
     */
    @RequestMapping("/findAllLocations")
    public Result findAllLocations() {
        try {
            List<Location> locationList = locationService.findAll();
            return new Result(true, MessageConstant.GET_LOCATION_LIST_SUCCESS, locationList);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_LOCATION_LIST_FAIL);
        }

    }
}
